{include file="public/header" /}


<div class="page">
    <div class="fixed-empty"></div>
    <form method="get" name="formSearch" id="formSearch">
        <div class="ds-search-form">
            <dl>
                <dt>{$Think.lang.goods_name}</dt>
                <dd><input type="text" value="{$Request.get.goods_name|default=''}" name="goods_name" id="goods_name"
                           class="txt">
                    <input type="hidden" value="{$member_id|default=''}" name="member_id">
                </dd>
            </dl>
            <div class="btn_group">
                <a href="javascript:void(0);" id="dssubmit" class="btn " title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a>
                <a href="{:url('Inviter/memberCommodity',['member_id'=>$member_id])}" class="btn btn-default" title="{$Think.lang.ds_cancel}">{$Think.lang.ds_cancel}</a>
                <a href="javascript:void(0);" class="btn btn-small" dstype="check_batch"><span>授权</span></a>
            </div>
        </div>
    </form>
    <table class="ds-default-table">
        <thead>
        <tr class="thead">
            <th class="w80"></th>
            <th class="w80"></th>
            <th class="">{$Think.lang.goods_name}</th>
            <th class="w180">{$Think.lang.inviter_ratio}</th>
            <th class="w80">{$Think.lang.goods_price}</th>
            <th class="w80">{$Think.lang.inviter_total_quantity}</th>
            <th class="w100">{$Think.lang.inviter_total_amount}</th>
            <th class="w100">{$Think.lang.inviter_amount}</th>
        </tr>
        </thead>
        <tbody>
        {notempty name="goods_list"}
        {foreach name="goods_list" item="val"}
        <tr class="hover edit">
            <td><input type="checkbox" value="{$val.goods_commonid}" {in name="$val.goods_commonid" value="$member_info.member_inviterids" } checked {/in} class="checkitem">
            </td>
            <td>
                <div class="pic-thumb"><img src="{:goods_thumb($val, 240)}"
                                            onload="javascript:ResizeImage(this,56,56);"/></div>
            </td>
            <td>{$val.goods_name}</td>
            <td>
                <p>{$Think.lang.inviter_ratio_1}{$val.inviter_ratio_1}{$Think.lang.ds_percent}</p>
                <p>{$Think.lang.inviter_ratio_2}{$val.inviter_ratio_2}{$Think.lang.ds_percent}</p>
                <p>{$Think.lang.inviter_ratio_3}{$val.inviter_ratio_3}{$Think.lang.ds_percent}</p>
            </td>
            <td>{$Think.lang.currency}{$val.goods_price}</td>
            <td>{$val.inviter_total_quantity}</td>
            <td>{$Think.lang.currency}{$val.inviter_total_amount}</td>
            <td>{$Think.lang.currency}{$val.inviter_amount}</td>
        </tr>
        <tr style="display:none;">
            <td colspan="8">
                <div class="dssc-goods-sku ps-container"></div>
            </td>
        </tr>
        {/foreach}
        {else /}
        <tr class="no_data">
            <td colspan="15">{$Think.lang.ds_no_record}</td>
        </tr>
        {/notempty}
        </tbody>
        <tfoot class="tfoot">
        {notempty name="goods_list"}
        <tr>
            <td class="w24"><input type="checkbox" class="checkall" id="checkallBottom"></td>
            <td colspan="16">
                <label for="checkallBottom">{$Think.lang.ds_select_all}</label>
            </td>
        </tr>
        {/notempty}
        </tfoot>
    </table>
    {$show_page}
</div>
<script type="text/javascript">
    $(function () {
        //按钮先执行验证再提交表单
        $('#dssubmit').click(function(){
            $('#formSearch').submit();
        });
    });

    // 审核批量处理
    $('a[dstype="check_batch"]').click(function () {
        ids_str = getItems();
        ids_all = getIds();
        goods_check(ids_str,ids_all);
    });
    function getIds() {
        var items = '';
        $('.checkitem').each(function () {
            items += this.value + ',';
        });
        items = items.substr(0, (items.length - 1));
        return items;
    }
    function getItems() {
        /* 获取选中的项 */
        var items = '';
        $('.checkitem:checked').each(function () {
            items += this.value + ',';
        });
        items = items.substr(0, (items.length - 1));
        return items;
    }

    // 商品审核
    function goods_check(ids_str,ids_all) {
        _uri = ADMINSITEURL + "/Inviter/goodsCheck?commonid=" + ids_str + "&member_id=" + "{$member_id}&ids_all="+ids_all;
        dsLayerOpen(_uri);
    }
</script>        